package config

import (
	"github.com/msbranco/goconfig"
	l "util/log"
)

type Config struct {
	ServIp     string
	ServPort   int
	CenterIp   string
	CenterPort int
}

func (cfg *Config) Load() bool {
	c, err := goconfig.ReadConfigFile("lister.cfg")
	if err != nil {
		l.TraceInfo("lister", "load lister.cfg error")
		return false
	}

	cfg.ServIp, _ = c.GetString("net", "ip")
	p, _ := c.GetInt64("net", "port")
	cfg.ServPort = int(p)

	cfg.CenterIp, _ = c.GetString("center", "ip")
	p, _ = c.GetInt64("center", "port")
	cfg.CenterPort = int(p)
	return true

}

func CreateConfig() *Config {
	return &Config{}
}
